package qianfeng.com.jswebproject.client;

import android.graphics.Bitmap;
import android.util.Log;
import android.webkit.WebView;
import android.webkit.WebViewClient;

/**
 */
public class MyWebViewClient extends WebViewClient {
    // 这两个对应的方法一般来控制进度条的显示和隐藏
    // 网页开始加载就会调用的方法
    private ClientCallBack mCallBack;

    public interface ClientCallBack{
        void onStart(String url);
        void onFinish(String url);
    }
    // 设置借口回调对象
    public void setClientListener(ClientCallBack clientListener){
        mCallBack = clientListener;
    }
    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {
        super.onPageStarted(view, url, favicon);
        if (mCallBack!=null){
            mCallBack.onStart(url);
        }
        Log.d("tag","onPageStarted == " +url);
    }
   // 加载结束的调用的方法
    @Override
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url);
        if (mCallBack!=null){
            mCallBack.onFinish(url);
        }
        Log.d("tag","onPageFinished == "+url);
    }
}
